<?php
	require ('function.php');
	$username = $_POST['username'];
	$password = $_POST['password'];
	session_start();
	if (isset ($_SESSION['valid_user'])){
		echo "You has logged in as ".$_SESSION['valid_user']."<br />";
		echo '<a href="menu.php" target=_blank>Menu</a>';
		}
	else{
		if($username && $password){
			try{
				user_register($username,$password);
				}
			catch(Exception $e){
				echo "Sorry,you failed";
				display_register();
				exit;
			}
		}
		else{
			display_register();
			exit;
			}
		$_SESSION['valid_user']=$username;
		echo '<a href=# onclick="location.href=location.href;">Refresh</a>';
	}
?>